package com.example.rwq_test.niuke.stack;

import java.util.PriorityQueue;

/**
 * TODO note
 *
 * @author renweiqiang
 * @version 1.0.0
 * @createTime 2023/12/22
 */
public class LostMinNumber {
    private static PriorityQueue<Integer> min = new PriorityQueue<>((o1, o2) -> o1.compareTo(o2));

    public static void main(String[] args) {
        int[] nums = {1, 3, 5, 2, 4, 6, 7, 8, 9};
        System.out.println(getLostMinNumber(nums));
    }

    private static int getLostMinNumber(int[] nums) {
        for (int num: nums) {
            if (num > 0) {
                min.offer(num);
            }
        }
        int result = 1;
        while (!min.isEmpty()) {
            int poll = min.poll();
            if (poll != result) {
                return result;
            }
            result++;
        }
        return result;
    }
}
